<?php
    // 查询 recruit 表
    function get_recruit_data(){
        $result = mysql_query("SELECT * FROM recruit");
  
        $results = array();
        while ($row = mysql_fetch_assoc($result)) {
            $results[] = $row;
        }


        $arrData = createJsonData($results);
    
        echo json_encode($arrData);
    }

    // 根据 id 获取 招聘信息
    function get_recruit_data_by_recruit_id($recruit_id){

        // var_dump($recruit_id);

        
        $result = mysql_query("SELECT * FROM recruit where recruit_id='" . $recruit_id . "'");
  
        $results = array();
        while ($row = mysql_fetch_assoc($result)) {
            $results[] = $row;
        }

        return $results;
        
    }

    // 简历批量删除接口
    function delete_many_recruit() {
        
        $sqlStr = "delete from recruit where recruit_id in (";

    
        foreach (json_decode($_POST["recruit_ids"] , true) as $value) {
            $sqlStr = $sqlStr."'".$value."',";
        }

        $sqlStr = substr($sqlStr,0,strlen($sqlStr)-1).")"; 

        $result = mysql_query($sqlStr);

        if ($result >= 1) {
            success_return("删除成功");
        } else {
            error_return("删除失败");
        }
    }


    function get_recruit_data_by_recruit_id_from_phone(){
        $result = mysql_query("SELECT * FROM recruit where recruit_id='$_POST[recruit_id]'");
  
        $results = array();
        while ($row = mysql_fetch_assoc($result)) {
            $results[] = $row;
        }

        $arrData = createJsonData($results);
        echo json_encode($arrData);
        
    }




    // 添加 recruit 数据
    function insert_recruit_data(){
        $recruitid = time() * 3;
        mysql_query("insert into recruit 
        (recruit_id , my_describe , title , my_require , job_position , 
        look_counts , deliver_counts , region , status , 
        release_time , company)  
        values 
        ('$recruitid' , '$_POST[describle]' , '$_POST[title]' , 
        '$_POST[require]' , '$_POST[job_position]' , 
        '$_POST[look_counts]' , '$_POST[deliver_counts]' , 
        '$_POST[region]' , '$_POST[status]' , 
        '$_POST[release_time]' , '$_POST[company]')");
        
    }

    // 发布 取消 发布
    function change_status() {
        mysql_query("update recruit set status = '$_POST[status]' 
        where 
        recruit_id='$_POST[recruit_id]'");
    }

    // 删除 recruit 一条 数据
    function delete_recruit_data(){
        mysql_query("delete from recruit where recruit_id='$_POST[recruit_id]'");
    }

    // 编辑 招聘 信息
    function update_recruit(){
        mysql_query("update recruit set 
        job_position='$_POST[job_position]' , 
        title='$_POST[title]' , 
        my_describe='$_POST[my_describe]' , 
        my_require='$_POST[my_require]' , 
        region='$_POST[region]' where 
        recruit_id='$_POST[recruit_id]'");
        
        
        
        $arrData = createJsonData(array());
        
        echo json_encode($arrData);
    }



?>